#@curdLayout()
#define main()
	<!-- PAGE CONTENT BEGINS -->
	<form method="post" class="form-horizontal" role="form">
		<div class="space-4"></div>
		<!-- #section:elements.form -->
		<div class="form-group">
			<input type="hidden" name="baseUser.id" value="#(user.id??)"/>
			<label class="col-sm-2 control-label no-padding-right" >用户名</label>
			<div class="col-sm-3">
				<input type="text" id="userName"  value="" placeholder="请输入用户名" class="form-control" />
			</div>
		</div>
		<div class="form-group" >
			<label class="col-sm-2 control-label no-padding-right" >密码</label>
			<div class="col-sm-3">
				<input type="password" id="password"  value="" placeholder="请输入密码" class="form-control" />
			</div>
		</div>
		
		<div class="space-4"></div>
		<!-- 按钮 -->
		<div style="text-align:center;margin-bottom:5px;">
			  	<button class="btn btn-sm btn-info" type="submit" id="btn_save">
					<i class="fa fa-check bigger-110"></i>
					获取
				</button>
				&nbsp; &nbsp; &nbsp;
				<button class="btn btn-sm" type="button" id="btn_close">
					<i class="fa fa-close bigger-110"></i>
					关闭
				</button>
		</div>
	</form>
	<script src="/static/validate/jquery-html5Validate.js"></script>
	<script type="text/javascript">
		var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
		$(function(){
			 $("form").html5Validate(function() {
					$("#btn_save").attr("disabled","disabled");
					var appindex = appLoading();
					var param = {};
					param.userName = $("#userName").val();
					param.password = $("#password").val();
					$.ajax({
						url: "/app/doLogin",
						type:'POST',
						dataType:'json',
						contentType:'application/json;charset=UTF-8',
						data:JSON.stringify(param),
						success:function(data, status){
							if (data.code == '200') {
								localStorage.setItem("token",data.data.accessToken);
								//重新获取token后同步token信息
								 var ifm = $("#iframe",window.parent.document).contents();
								 ifm.find("#headername").val("token");
								 ifm.find("#headervalue").val(data.data.accessToken);
								clearLoading(appindex);
								layer.msg("获取成功!", {icon: 1});
								setTimeout(function(){
									parent.layer.close(index);
								},500);
								return false;
							} else {
								clearLoading(appindex);
								$("#btn_save").removeAttr("disabled","disabled");
								if(data.state=='fail'){
									layer.alert(data.msg, {icon: 5,title:"发生错误"});
								}
								else{
									layer.msg(data.msg, {icon: 2,time:2000});
								}
								return false;
							}
						}
					})
				return false;
			}, {
				// novalidate: false
			});
			
			$("#btn_close").bind("click",function(){
				parent.layer.close(index);
			});
		});
	</script>
#end	
